package com.liu.udpChat;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class UDPSender {
    public static void main(String[] args) throws Exception{
        Scanner scanner=new Scanner(System.in);
        DatagramSocket socket = new DatagramSocket(6789);
        InetAddress inetAddress=InetAddress.getByName("127.0.0.1");
        while (true) {
            String str=scanner.next();
            DatagramPacket packet = new DatagramPacket(str.getBytes(),0,str.getBytes().length,inetAddress,9876);
            socket.send(packet);
            if (str.equals("bye")){
                break;
            }
        }
        socket.close();
    }
}
